<div  class='menu'
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:py="http://purl.org/kid/ns#">

    <div py:def="display_submenu(obj)">
        <a py:if="not obj['href'] is None and obj['href'].strip()!='' " href="${obj['href']}">${obj['name']}</a>
        <div py:if="obj['href'] is None or obj['href'].strip()=='' " >${obj['name']}</div>
    </div>
    <ul>
            <li py:for="main in mainmenu" class="mainmenu" >
                ${display_submenu(main)}
                <ul py:if="main['subs']">
                   <li py:for="level1 in main['subs']" class="submenu">
                        ${display_submenu(level1)}
                        <ul py:if="level1['subs']">
                            <li py:for="level2 in level1['subs']" class="submenu">
                                ${display_submenu(level2)}
                            </li>
                        </ul>
                   </li>
                </ul>
            </li>
    </ul>
 </div>